<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input
       :disabled="userState"
        v-model="queryParams.name"
        placeholder="场站名称"
        style="width: 200px"
        class="filter-item"
        @keyup.enter.native="queryBtn"
      />
      <el-button
       :disabled="userState"
        v-waves
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        style="margin-left: 5px"
        @click="queryBtn"
      >
        查询
      </el-button>
      <!--   <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">
        添加
      </el-button>
    -->
  
    <span style="float: right;
    margin-right: 20px;
    font-weight: 600;color: #494949;">当前账号：<span style="color: #ff770f;">{{title}}</span></span>
  
  </div>

    

    <el-table
      :header-cell-style="{ background: '#ffffff', color: '#000000' }"
      :key="tableKey"
      :row-class-name="tableRowClassName"
      v-loading="listLoading"
      :data="list"
      :row-key="'id'"
      :stripe=true
      ref="parkfieldTable"
      @selection-change="handleTableChange"
      border
      fit
      highlight-current-row
      style="
        width: 100%;
        font-size: 15px;
        box-shadow: 1px 1px 8px #cdcdcd;
        border: 0px;
      "
      :default-sort="{ prop: 'time', order: 'descending' }"
    >
      <!-- <el-table-column
        label="ID"
        prop="id"
        sortable="custom"
        align="center"
        width="80"
        :class-name="getSortClass('id')"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column> -->

      <el-table-column label="场站名称" min-width="160px">
        <template slot-scope="scope">
          <span>{{ scope.row.name }}</span>
        </template>
      </el-table-column>

      <el-table-column label="地址" min-width="220px">
        <template slot-scope="scope">
          <span>{{ scope.row.address }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="电费"
        min-width="70px"
        property="electricFee2"
        align="center"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.electricFee2 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="服务费" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.serviceFee }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="占位费" min-width="100px">
        <template slot-scope="{row}">
          <span>{{ row.occupiedFee }}</span>
        </template>
      </el-table-column> -->

      <el-table-column label="启用时间" min-width="160px">
        <template slot-scope="scope">
          <span>{{ sub(scope.row.createDate) }}</span>
        </template>
      </el-table-column>



      <el-table-column label="占位收费机制" width="140" fixed="right" align="center">
      <template slot-scope="scope">
       <el-button :disabled="userState" class="operateBtn" size="mini" type="primary" @click="editBtn(scope.$index, scope.row)" title="编辑"><i class="el-icon-edit-outline"></i></el-button>
      </template>
      </el-table-column>

      <!-- <el-table-column label="充值优惠" width="100px" align="center">
        <template slot-scope="{ row }">
          <span></span>
        </template>
      </el-table-column> -->

      <!-- <el-table-column
        label="操作"
        fixed="right"
        align="center"
        width="100"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="{ row }">
          <el-button type="primary" size="mini" @click="handleUpdate(row)">
            <i class="el-icon-edit"></i>
            修改
          </el-button>
        </template>
      </el-table-column> -->
    </el-table>

    <el-row>
      <el-col :span="24" class="page-tool">
        <el-pagination
          layout="total,sizes,prev, pager,next,jumper"
          style="margin-top: 10px"
          :page-size="pageSize"
          :total="total"
          :page-sizes="[10, 20, 30, 40]"
          @size-change="handlePageChange"
          @current-change="handleNoChange"
        ></el-pagination>
      </el-col>
    </el-row>

 <el-dialog :title="dialogTitle" :visible.sync="addDialog2" :width="'422px'">
      <el-form :model="form" :rules="rules" ref="form">
        <el-form-item label="占位收费时间" :label-width="labelWidth" required>
          <template>
            <el-col :span="8">
              <el-form-item prop="dayFree">
                <el-select v-model="form.dayFree" placeholder="" @change="changeManager(form.dayFree)" style="width: 70px;">
                  <el-option v-for="hour in hours" v-bind:key="hour" :label="hour" :value="hour"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col class="line" :span="2">-</el-col>
            <el-col :span="8">
              <el-form-item prop="nightFree">
                <el-select v-model="form.nightFree" placeholder="" @change="changeManager(form.nightFree)" style="width: 70px;">
                  <el-option v-for="hour in hours" v-bind:key="hour" :label="hour" :value="hour"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </template>
        </el-form-item>

        <el-form-item label="占位生效时间" :label-width="labelWidth" prop="occupiedIssuedDate">
          <el-date-picker
            v-model="form.occupiedIssuedDate"
            type="datetime"
            placeholder="选择日期"
            auto-complete="off">
          </el-date-picker>
        </el-form-item>
      </el-form>
     <div slot="footer" class="dialog-footer">
        <el-button @click="addDialog2 = false">取 消</el-button>
        <el-button type="primary" @click="updateParkfield()">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogPvVisible" title="Reading statistics">
      <el-table
        :data="pvData"
        border
        fit
        highlight-current-row
        style="width: 100%"
      >
        <el-table-column prop="key" label="Channel" />
        <el-table-column prop="pv" label="Pv" />
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogPvVisible = false"
          >Confirm</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<style>

.page-tool {
  background: rgb(237, 231, 231);
}

.page-tool div {
  text-align: right;
}

.lock-btn {
  margin-bottom: 5px;
  margin-top: -10px;
}
.operateBtn {
  font-size: 18px;
  width: 32px;
  height: 32px;
  padding: 0;
}

.el-table .warning-row {
  background: #fff5ee;
}
.el-table__body tr:hover > td {
  background-color: #fdc091;
}
.el-table__body tr.current-row > td {
  background-color: #fdc091;
}
</style>


<script>
import { listParkfield, setLcParkfieldParam } from "@/api/parkfield";
import waves from "@/directive/waves"; // waves directive
import { loadFeedbackApi,updateParkfieldApi,batchUpdatePriceApi} from "@/api/car";
import { getNickName, getTestUserName } from "../../utils/auth";

import { parseTime } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination

const calendarTypeOptions = [
  { key: "CN", display_name: "China" },
  { key: "US", display_name: "USA" },
  { key: "JP", display_name: "Japan" },
  { key: "EU", display_name: "Eurozone" },
];

// arr to obj, such as { CN : "China", US : "USA" }
// const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
//   acc[cur.key] = cur.display_name;
//   return acc;
// }, {});

export default {
  name: "ComplexTable",
  components: { Pagination },
  directives: { waves },
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "info",
        deleted: "danger",
      };
      return statusMap[status];
    },
    typeFilter(type) {
      return calendarTypeKeyValue[type];
    },
  },
  queryParams: {
    name: "",
  },
  
  data() {
    return {
      queryParams: {
        name: "",
      },
      rules: {
        dayFree: [
            { required: true, message: '请选择占位收费时间', trigger: 'change' }
          ],
        nightFree: [
            { required: true, message: '请选择占位收费时间', trigger: 'change' }
          ]      
      },
      feeRules: {
        freeTime: [
            { required: true, message: '请选择免费时间', trigger: 'blur' }
          ],
        occupiedFee: [
            { required: true, message: '请输入占位费', trigger: 'blur' }
          ],
        electricFee: [
            { required: true, message: '请输入执行电价', trigger: 'blur' }
          ],
        startTime1: [
            { required: true, message: '请选择起始时间', trigger: 'blur' }
          ],
        endTime1: [
            { required: true, message: '请选择结束时间', trigger: 'blur' }
          ],
        electricFee1: [
            { required: true, message: '请设置收费价格(尖)', trigger: 'blur' },
            { pattern: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/, message: '请输入正确价格' },
          ],
        startTime2: [
            { required: true, message: '请选择起始时间', trigger: 'blur' }
          ],
        endTime2: [
            { required: true, message: '请选择结束时间', trigger: 'blur' }
          ],
        electricFee2: [
            { required: true, message: '请设置收费价格(峰)', trigger: 'blur' },
            { pattern: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/, message: '请输入正确价格' },
          ],
        startTime3: [
            { required: true, message: '请选择起始时间', trigger: 'blur' }
          ],
        endTime3: [
            { required: true, message: '请选择结束时间', trigger: 'blur' }
          ],
        electricFee3: [
            { required: true, message: '请设置收费价格(平)', trigger: 'blur' },
            { pattern: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/, message: '请输入正确价格' },
          ],
        startTime4: [
            { required: true, message: '请选择起始时间', trigger: 'blur' }
          ],
        endTime4: [
            { required: true, message: '请选择结束时间', trigger: 'blur' }
          ],
        electricFee4: [
            { required: true, message: '请设置收费价格(谷)', trigger: 'blur' },
            { pattern: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/, message: '请输入正确价格' }
          ],
      },
      roleIndex: true,
      dialogTitle: "设置停车场",
      addDialog: false,
      addDialog2: false,
      labelWidth: "120px",
      form: {},
      hours: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],
      roleIndex: true,
      multipleSelection: [],
      tableKey: 0,
      list: [],
      total: 0,
      promotionDialogTitle: "",
      promotionDialog: false,
      editFeeDialog: false,
      feeForm: {
        freeTime: 0,
        occupiedFee: "",
        electricFee: "",
        oriFee: "",
        serviceFee: "",
        startTime1: "",
        endTime1: "",
        electricFee1: "",
        startTime2: "",
        endTime2: "",
        electricFee2: "",
        startTime3: "",
        endTime3: "",
        electricFee3: "",
        startTime4: "",
        endTime4: "",
        electricFee4: ""
      },
      timeSharing: false,
      //  sortable:true,
      currentPage: 1,
      title:"",
      pageSizes: [10, 20, 40],
      pageNo: 1,
      pageSize: 20,
      listLoading: true,
      listQuery: {
        pageNo: 1,
        pageSize: 41,
        name: undefined,
        phone: undefined,
        number: undefined,
        sort: "+id",
      },
      form:{},
      promotionForm: {
        name: "",
        desc: "",
        effectiveDate: "",
        deadlineDate: "",
        depositAmount1: "",
        bonusAmount1: "",
        depositAmount2: "",
        bonusAmount2: "",
        depositAmount3: "",
        bonusAmount3: "",
        depositAmount4: "",
        bonusAmount4: "",
        acitivityContent: [],
      },
      importanceOptions: [1, 2, 3],
      calendarTypeOptions,
      sortOptions: [
        { label: "ID Ascending", key: "+id" },
        { label: "ID Descending", key: "-id" },
      ],
      statusOptions: ["published", "draft", "deleted"],
      showReviewer: false,
      temp: {
        id: undefined,
        importance: 1,
        remark: "",
        timestamp: new Date(),
        title: "",
        type: "",
        status: "published",
      },
      dialogFormVisible: false,
      dialogStatus: "",
      textMap: {
        update: "编辑",
        create: "Create",
      },
      searchVal: "", //默认输入为空
      letter: "", //默认不排序
      original: false, //默认从小到大排列
      dialogPvVisible: false,
      pvData: [],
      key:"",
      downloadLoading: false,
    };
  },

  created() {},
  //   computed: {
  //   userState () {
  //     return getNickName() === getTestUserName();
  //   }
  // },
  mounted: function () {
    this.key = localStorage.getItem("key");
    this.title = localStorage.getItem("title");
    this.$nextTick(function () {
      this.loadFeedback(this.pageNo, this.pageSize);
    });
  },

  computed: {
    userState () {
      return getNickName() === getTestUserName();
    }
  },
  

  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 0) {
        return "warning-row";
      }
      return "";
    },

     timeSharingChange () {
      let _this = this;
  //    console.log(_this.timeSharing)
    },
    sub(value) {
      if (value === null || undefined) {
        return "";
      } else {
        value = value.substring(0, 16);
        return value;
      }
    },
    sortByPurchase(obj1, obj2) {
      var a = obj1.electricFee2;
      var b = obj2.electricFee2;
      return a - b;
    },
    // getList(pageNo, pageSize) {
    //   this.listLoading = true;
    //   loadFeedbackApi(pageNo, pageSize).then(response => {
    //     this.list = response.data.dataList
    //     this.total = response.data.totalNum
    //     // Just to simulate the time of the request
    //     setTimeout(() => {
    //       this.listLoading = false
    //     }, 1.5 * 1000)
    //   })
    // },
    handleFilter() {
      this.listQuery.pageNo = 1;
   //   this.getList();
    },
    handleModifyStatus(row, status) {
      this.$message({
        message: "操作Success",
        type: "success",
      });
      row.status = status;
    },

    //列表页码的触发事件
    handlePageChange(pageSize) {
      this.pageSize = pageSize;
      this.loadFeedback(this.pageNo, this.pageSize);
    },
    handleNoChange(pageNo) {
      this.pageNo = pageNo;
      this.loadFeedback(this.pageNo, this.pageSize);
    },
    handleTableChange(val) {
      this.multipleSelection = val;
    },
    loadFeedback(pageNo, pageSize) {
      let _this = this;
      _this.loading = true;
      loadFeedbackApi({
        pageNo: pageNo,
        pageSize: pageSize,
        name: _this.queryParams.name,
        roleCode:_this.key
      }).then((response) => {
        _this.list = response.data.dataList;
        _this.total = response.data.totalNum;
        setTimeout(() => {
          _this.listLoading = false;
        }, 1 * 1000);
      });
    },
    queryBtn() {
      let _this = this;
      _this.loading = true;
      this.loadFeedback(_this.pageNo, _this.pageSize);
    },

    resetTemp() {
      this.temp = {
        id: undefined,
        importance: 1,
        remark: "",
        timestamp: new Date(),
        title: "",
        status: "published",
        type: "",
      };
    },
    handleCreate() {
      this.resetTemp();
      this.dialogStatus = "create";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["feeForm"].clearValidate();
      });
    },
    createData() {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          addCar(this.temp).then(() => {
        //    this.getList();
            this.dialogFormVisible = false;
            this.$notify({
              title: "Success",
              message: "Created Successfully",
              type: "success",
              duration: 2000,
            });
          });
        }
      });
    },
    handleUpdate(row) {
      this.temp = Object.assign({}, row); // copy obj
      this.temp.timestamp = new Date(this.temp.timestamp);
      this.dialogStatus = "update";
      this.editFeeDialog = true;
      // this.$nextTick(() => {
      //   this.$refs["dataForm"].clearValidate();
      // });
    },
    editBtn (index, row) {
      let _this = this;
      _this.$nextTick(()=>{
        if(_this.$refs.form != undefined){
          _this.$refs.form.resetFields();
        }
      });
      //   loadFeedbackApi({pageNo:_this.pageNo,pageSize:_this.pageSize}).then(resp => {
      //   _this.list = resp.data.dataList;
      //   _this.total = resp.data.totalNum
      // });   
      _this.form = row;
      _this.selectDisable = true;
      _this.addDialog2 = true;
    },


    // loadFeedbackApi({
    //     pageNo: pageNo,
    //     pageSize: pageSize,
    //     name: _this.queryParams.name,

    updateData() {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          updateCar(this.temp).then(() => {
         //   this.getList();
            this.dialogFormVisible = false;
            this.$notify({
              title: "Success",
              message: "Update Successfully",
              type: "success",
              duration: 2000,
            });
          });
        }
      });
    },
    handleDelete(row, index) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        deleteCar({ id: row.id }).then(() => {
      //    this.getList();
          this.dialogFormVisible = false;
          this.$notify({
            title: "Success",
            message: "Delete Successfully",
            type: "success",
            duration: 2000,
          });
        });
      });
    },
    handleFetchPv(pv) {
      fetchPv(pv).then((response) => {
        this.pvData = response.data.pvData;
        this.dialogPvVisible = true;
      });
    },
    handleDownload() {
      this.downloadLoading = true;
      import("@/vendor/Export2Excel").then((excel) => {
        const tHeader = ["timestamp", "title", "type", "importance", "status"];
        const filterVal = [
          "timestamp",
          "title",
          "type",
          "importance",
          "status",
        ];
        const data = this.formatJson(filterVal);
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: "table-list",
        });
        this.downloadLoading = false;
      });
    },
    formatJson(filterVal) {
      return this.list.map((v) =>
        filterVal.map((j) => {
          if (j === "timestamp") {
            return parseTime(v[j]);
          } else {
            return v[j];
          }
        })
      );
    },
    getSortClass: function (key) {
      const sort = this.listQuery.sort;
      return sort === `+${key}` ? "ascending" : "descending";
    },
    
    batchChangePriceSubmit () {
      let _this = this;
      _this.$refs.feeForm.validate((valid) => {
        if (valid) {
          let ids = new Array();
          for (let i = 0; i < _this.multipleSelection.length; i++) {
            ids[i] = _this.multipleSelection[i].id
          }
 
          let data;
          if(!_this.timeSharing){
            data = {
              ids: ids,
              freeTime: _this.feeForm.freeTime,
              occupiedFee: parseFloat(_this.feeForm.occupiedFee),
              electricFee: parseFloat(_this.feeForm.electricFee),
              oriFee: parseFloat(_this.feeForm.oriFee),
              // serviceFee: parseFloat(_this.feeForm.serviceFee),
            }
          }else{
            if(!_this.judgeTime1(_this.feeForm.startTime1,_this.feeForm.endTime1,_this.feeForm.startTime2,_this.feeForm.endTime2)){
              this.$message({
                message: "尖时间区间与峰时间区间交叉！",
                type: "warning"
              });
              return;
            }
            if(!_this.judgeTime1(_this.feeForm.startTime1,_this.feeForm.endTime1,_this.feeForm.startTime3,_this.feeForm.endTime3)){
              this.$message({
                message: "尖时间区间与平时间区间交叉！",
                type: "warning"
              });
              return;
            }
            if(!_this.judgeTime1(_this.feeForm.startTime1,_this.feeForm.endTime1,_this.feeForm.startTime4,_this.feeForm.endTime4)){
              this.$message({
                message: "尖时间区间与谷时间区间交叉！",
                type: "warning"
              });
              return;
            }
            if(!_this.judgeTime1(_this.feeForm.startTime2,_this.feeForm.endTime2,_this.feeForm.startTime3,_this.feeForm.endTime3)){
              this.$message({
                message: "峰时间区间与平时间区间交叉！",
                type: "warning"
              });
              return;
            }
            if(!_this.judgeTime1(_this.feeForm.startTime2,_this.feeForm.endTime2,_this.feeForm.startTime4,_this.feeForm.endTime4)){
              this.$message({
                message: "峰时间区间与谷时间区间交叉！",
                type: "warning"
              });
              return;
            }
            if(!_this.judgeTime1(_this.feeForm.startTime3,_this.feeForm.endTime3,_this.feeForm.startTime4,_this.feeForm.endTime4)){
              this.$message({
                message: "平时间区间与谷时间区间交叉！",
                type: "warning"
              });
              return;
            }
            // if(!_this.judgeTime()){
            //   this.$message({
            //     message: "设置的时间段总和不足24小时！",
            //     type: "warning"
            //   });
            //   return;
            // }
            data = {
              ids: ids,
              freeTime: _this.feeForm.freeTime,
              occupiedFee: parseFloat(_this.feeForm.occupiedFee),
              oriFee: parseFloat(_this.feeForm.oriFee),
              // serviceFee: parseFloat(_this.feeForm.serviceFee),
              interval1: _this.feeForm.startTime1 + '-' + (_this.feeForm.endTime1),
              interval2: _this.feeForm.startTime2 + '-' + (_this.feeForm.endTime2),
              interval3: _this.feeForm.startTime3 + '-' + (_this.feeForm.endTime3),
              interval4: _this.feeForm.startTime4 + '-' + (_this.feeForm.endTime4),
              electricFee1: parseFloat(_this.feeForm.electricFee1),
              electricFee2: parseFloat(_this.feeForm.electricFee2),
              electricFee3: parseFloat(_this.feeForm.electricFee3),
              electricFee4: parseFloat(_this.feeForm.electricFee4),
            }
          }
          
          batchUpdatePriceApi(data).then(
            function (resp) {
              // _this.multipleSelection = []
              // _this.$refs.chargerTable.clearSelection();
              if (resp.errmsg === "ok") {
                _this.$notify({
                  title: "成功",
                  message: "价格修改成功",
                  type: "success"
                });
                _this.editFeeDialog = false
              } else {
                _this.$notify({
                  title: "失败",
                  message: "价格修改失败，请稍后重试。",
                  type: "error"
                });
              }
            }
          );
        }
      });
    },

    compareDate(t1,t2){//两个时间相等
      var date = new Date();
      var a = t1.split(":");
      var b = t2.split(":");
      return date.setHours(a[0],a[1]) == date.setHours(b[0],b[1]);
    },
        compareDate1(t1,t2){//t1大于t2
      var date = new Date();
      var a = t1.split(":");
      var b = t2.split(":");
      return date.setHours(a[0],a[1]) > date.setHours(b[0],b[1]);
    },


        judgeTime1(startTime1, endTime1, startTime2, endTime2){
      let _this = this;
      if(_this.compareDate1(endTime2,startTime2)){
        if(_this.compareDate1(startTime1,startTime2) && _this.compareDate1(endTime2,startTime1)){
          return false;
        }
        if(_this.compareDate1(endTime1,startTime2) && _this.compareDate1(endTime2,endTime1)){
          return false;
        }
        if(_this.compareDate1(endTime1,endTime2) && _this.compareDate1(startTime2,startTime1)){
          return false;
        }
        if(_this.compareDate1(endTime2,endTime1) && _this.compareDate1(startTime1,startTime2)){
          return false;
        }
      }
      if(_this.compareDate1(startTime2,endTime2)){
        if(_this.compareDate1(startTime1,startTime2)){
          return false;
        }
        if(_this.compareDate1(endTime1,startTime2)){
          return false;
        }
        if(_this.compareDate1(startTime1,startTime2) && _this.compareDate1(endTime2,startTime1)){
          return false;
        }
        if(_this.compareDate1(startTime2,startTime1) && _this.compareDate1(endTime1,endTime2)){
          return false;
        }
      }
      if(_this.compareDate1(endTime1,startTime1)){
        if(_this.compareDate1(startTime2,startTime1) && _this.compareDate1(endTime1,startTime2)){
          return false;
        }
        if(_this.compareDate1(endTime2,startTime1) && _this.compareDate1(endTime1,endTime2)){
          return false;
        }
        if(_this.compareDate1(endTime2,endTime1) && _this.compareDate1(startTime1,startTime2)){
          return false;
        }
        if(_this.compareDate1(endTime1,endTime2) && _this.compareDate1(startTime2,startTime1)){
          return false;
        }
      }
      if(_this.compareDate1(startTime1,endTime1)){
        if(_this.compareDate1(startTime2,startTime1)){
          return false;
        }
        if(_this.compareDate1(endTime2,startTime1)){
          return false;
        }
        if(_this.compareDate1(startTime2,startTime1) && _this.compareDate1(endTime1,startTime2)){
          return false;
        }
        if(_this.compareDate1(startTime1,startTime2) && _this.compareDate1(endTime2,endTime1)){
          return false;
        }
      }
      return true;
    },
    judgeTime(){//判断设置时间断总和是否等于24小时
      let _this = this;
   //   console.log(_this.feeForm)
      var endTime1 = _this.feeForm.endTime1 === '24:00' ? '00:00' : _this.feeForm.endTime1
      var endTime2 = _this.feeForm.endTime2 === '24:00' ? '00:00' : _this.feeForm.endTime2
      var endTime3 = _this.feeForm.endTime3 === '24:00' ? '00:00' : _this.feeForm.endTime3
      var endTime4 = _this.feeForm.endTime4 === '24:00' ? '00:00' : _this.feeForm.endTime4
      
      if(_this.compareDate(_this.feeForm.startTime1,endTime2)){
        if(_this.compareDate(_this.feeForm.startTime2,endTime1)){
          if(_this.compareDate(_this.feeForm.startTime3,endTime4)){
            if(_this.compareDate(_this.feeForm.startTime4,endTime3)){
              return true;
            }
          }
        }
        if(_this.compareDate(_this.feeForm.startTime2,endTime3)){
          if(_this.compareDate(_this.feeForm.startTime3,endTime4)){
            if(_this.compareDate(_this.feeForm.startTime4,endTime1)){
              return true;
            }
          }
        }
        if(_this.compareDate(_this.feeForm.startTime2,endTime4)){
          if(_this.compareDate(_this.feeForm.startTime3,endTime1)){
            if(_this.compareDate(_this.feeForm.startTime4,endTime3)){
              return true;
            }
          }
        }
      }
      },

    updateParkfield () {

      let _this = this;
      _this.$refs.form.validate((valid) => {
        if (valid) {
            if(Number(_this.form.dayFree) > Number(_this.form.nightFree)){
              _this.$notify({
                title: "失败",
                message: "免费开始时间不能大于结束时间",
                type: "error"
              });
              return;
            }
            if(_this.form.occupiedIssuedDate != undefined && _this.form.occupiedIssuedDate != null && _this.form.occupiedIssuedDate != ''){
              _this.form.occupiedIssuedDate = _this.moment(_this.form.occupiedIssuedDate).format("YYYY-MM-DD HH:mm:ss")
            }
            if (_this.dialogTitle === "设置停车场") {
                updateParkfieldApi(_this.form).then(resp => {
              _this.addDialog2 = false;
              if (resp.errmsg === "ok") {
                _this.loadFeedback(_this.pageNo, _this.pageSize);
                _this.$notify({
                  title: "成功",
                  message: "停车场修改成功",
                  type: "success"
                });
              } else {
                _this.$notify({
                  title: "失败",
                  message: "停车场修改失败",
                  type: "error"
                });
              }
            });
          }
        } else {
          return false;
        }
      });
    },

  },


    batchChangePrice(){

      
      // let _this = this;

      // _this.$nextTick(()=>{
      //   if(_this.$refs.feeForm != undefined){
      //       _this.$refs.feeForm.resetFields();
      //     }
      // })
      // _this.timeSharing = false
      // _this.feeForm = {
      //   freeTime: 0,
      //   occupiedFee: "",
      //   electricFee: "",
      //   oriFee: "",
      //   serviceFee: "",
      //   startTime1: "",
      //   endTime1: "",
      //   electricFee1: "",
      //   startTime2: "",
      //   endTime2: "",
      //   electricFee2: "",
      //   startTime3: "",
      //   endTime3: "",
      //   electricFee3: "",
      //   startTime4: "",
      //   endTime4: "",
      //   electricFee4: ""
      // }
      // _this.editFeeDialog = true
    },

};



</script>


